import React from 'react'
import "../../styles/sidebar/login.css"
import { withRouter } from "react-router-dom";
import axios from 'axios'
axios.default.widthCredentials = true

class Login extends React.Component {
    constructor() {
        super()
        this.state = {
            profile: ''
        }
    }

    componentDidMount() {
        let profile = JSON.parse(localStorage.getItem("profile"))
        // console.log(profile)
        this.setState({
            profile: profile
        })
    }

    goMyself() {
        this.props.history.push('/website/music')
    }

    render() {
        let { profile } = this.state

        return (
            <div>
                <div className='sid-log' onClick={this.goMyself.bind(this)}>
                    <div className="sid-log-img">
                        <img src={profile.avatarUrl} alt="" />
                    </div>
                    <div className="sid-log-name clearfix">
                        <i>{profile.nickname}</i>
                        <span>lv.{profile.playlistCount}</span>
                        <p className='sid-log-jd'>签到</p>
                    </div>

                </div>
            </div>
        )
    }
}

export default withRouter(Login)